<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue基础</title>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<H3>声明式渲染</H3>
<div id="app">
    {{ message }}
</div>
<H3>绑定消息</H3>
<div id="app-2">
  <span v-bind:title="message">
    鼠标悬停几秒钟查看此处动态绑定的提示信息！
  </span>
</div>
<H3>是否显示</H3>
<div id="app-3">
    <p v-if="seen">现在你看到我了</p>
</div>

<H3>条件循环</H3>
<div id="app-4">
    <p v-if="seen">现在你看到我了</p>
</div>

<H3>遍历</H3>
<div id="app-41">
    <ol>
        <li v-for="todo in todos">
            {{ todo.text }}
        </li>
    </ol>
</div>

<H3>事件监听</H3>
<div id="app-5">
    <p>{{ message }}</p>
    <button v-on:click="reverseMessage">反转消息</button>
</div>

<H3>表单输入和应用状态之间的双向绑定</H3>
<div id="app-6">
    <p>{{ message }}</p>
    <input v-model="message">
</div>

<script>

    var app = new Vue({
        el: "#app",
        data: {
            message:"hello word!"
        }
    })

    var app2 = new Vue({
        el: '#app-2',
        data: {
            message: '页面加载于 ' + new Date().toLocaleString()
        }
    })


    var app3 = new Vue({
        el: '#app-3',
        data: {
            seen: true
        }
    })


    var app4 = new Vue({
        el: '#app-4',
        data: {
            seen: true
        }
    })

    var app41 = new Vue({
        el: '#app-41',
        data: {
            todos: [
                { text: '学习 JavaScript' },
                { text: '学习 Vue' },
                { text: '整个牛项目' }
            ]
        }
    })


    var app5 = new Vue({
        el: '#app-5',
        data: {
            message: 'Hello Vue.js!'
        },
        methods: {
            reverseMessage: function () {
                this.message = this.message.split('').reverse().join('')
            }
        }
    })

    var app6 = new Vue({
        el: '#app-6',
        data: {
            message: 'Hello Vue!'
        }
    })
</script>

</body>
</html>